Fixing database issues....<br>
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/*
 * 1. get list of *.sql tables
 *    for each file
 *        IF table Does not exist
 *              CREATE
 *        ELSE
 *            FOR each column in table
 *                IF column does not exist
 *                   Add column
 *                END IF
 *            END FOR
 *        END IF
 *    END FOR
 *
 */

//http://127.0.0.1/pacts/index.php?view=SetupSqlTables&type=setup

// Set global object with config and functions
require_once ('_includes/class_includes.php');

//Create global configuration object
$PACTS_cfg = new PactsCfg();
$PACTS_cfg->init(false,false,false);
$table = "Users";


//Fix SQL issues
$bSqlSetupOk = $PACTS_cfg->checkSqlSetup(true,true);

if ($bSqlSetupOk){
    echo 'Sql Setup issues Fixed.<br>';
} else {
    echo 'There was a problem fixing the issue with the sql setup<br>';
}

$bUserAccountsNotOk = $PACTS_cfg->checkUserAccounts(true);
if (!$bUserAccountsNotOk){
    echo 'User issues Fixed.<br>';
} else {
    echo 'There was a problem fixing the issue with user acounts<br>';
}



$bRefDataOk = $PACTS_cfg->checkRefData(true,true);
if ($bRefDataOk){
    echo 'Reference data issues Fixed. Click <a href="index.php">here</a> to login.<br>';
} else {
    echo 'There was a problem fixing the issue with the reference data<br>';
}




    $bRefDataOk = $PACTS_cfg->addSampleData(true,true);
    if ($bRefDataOk){
        echo 'Sample data addd. Click <a href="index.php">here</a> to login.<br>';
    } else {
        echo 'There was a problem adding sample data to the database<br>';
    }
smaple data



echo 'Click <a href="index.php">here</a> to login.<br>';



//check columns...
/* 1. read sql.
   2. replace tablename with _tmp
 * 3. create _tmp
 * 4. check columns against real table
 * 5. create/alter missing columns (do not delete)
 * 6. delete _tmp
 *
 */
?>
